package com.example.demo.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import com.example.demo.domain.RepairProcess;

/**
 *  @author w
 */
@Transactional(rollbackFor = Exception.class)
public interface RepairProcessRepository extends JpaRepository<RepairProcess, Integer>,JpaSpecificationExecutor<RepairProcess>{
    List<RepairProcess> findAll();
    List<RepairProcess> findByTrainId(String trainId);
    //List<RepairProcess> findByStartTimeStartingWith(String startTime);
    @Transactional
    @Query(value = "select * from repair_process where left(start_time,4)=?1",nativeQuery = true)
    List <RepairProcess> findByYear(String year);
    List <RepairProcess> deleteByTrainId(String trainId);
}